package com.g17.virtualpetbackend;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
class ImageConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //和页面有关的静态目录都放在项目的static目录下
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        //上传的图片在D盘下的upLoadImg目录下，访问路径如：http://localhost:8081/upLoadImg/d3cf0281-bb7f-40e0-ab77-406db95ccf2c.jpg
        //其中OTA表示访问的前缀。"file:D:/upLoadImg/"是文件真实的存储路径upLoadImg
        registry.addResourceHandler("/upLoadImg/**").addResourceLocations("file:C:/upLoadImg/");
        registry.addResourceHandler("/upLoadVideo/**").addResourceLocations("file:C:/upLoadVideo/");
    }
}

@SpringBootApplication
public class VirtualPetBackendApplication {

    public static void main(String[] args) {
        SpringApplication.run(VirtualPetBackendApplication.class, args);
    }

}
